package com.zhiyu.util;

import com.zhiyu.config.ReturnCodeConfig;
import com.zhiyu.entity.VO.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ResponseUtil {

    @Autowired
    private ReturnCodeConfig returnCodeConfig;

    public ResponseVO success() {
        return new ResponseVO(returnCodeConfig.getSuccessCode(), returnCodeConfig.getSuccessMessage());
    }

    public ResponseVO fieldInvalid() {
        return new ResponseVO(returnCodeConfig.getFieldInvalidCode(), returnCodeConfig.getFieldInvalidMessage());
    }

    public ResponseVO loginFail() {
        return new ResponseVO(returnCodeConfig.getLoginFailCode(), returnCodeConfig.getLoginFailMessage());
    }

    public ResponseVO accountExisited() {
        return new ResponseVO(returnCodeConfig.getAccountExisitedCode(), returnCodeConfig.getAccountExisitedMessage());
    }

    public ResponseVO registerFail() {
        return new ResponseVO(returnCodeConfig.getRegisterFailCode(), returnCodeConfig.getRegisterFailMessage());
    }

    public ResponseVO tokenInvalid() {
        return new ResponseVO(returnCodeConfig.getTokenInvalidCode(), returnCodeConfig.getTokenInvalidMessage());
    }

    public ResponseVO noPermission() {
        return new ResponseVO(returnCodeConfig.getNoPermissionCode(), returnCodeConfig.getNoPermissionMessage());
    }

    public ResponseVO requireAuthentication() {
        return new ResponseVO(returnCodeConfig.getRequireAuthenticationCode(), returnCodeConfig.getRequireAuthenticationMessage());
    }

    public ResponseVO invalidResource() {
        return new ResponseVO(returnCodeConfig.getInvalidResourceCode(), returnCodeConfig.getInvalidResourceMessage());
    }
}
